<template>
  <div>
     <!--  商品列表  -->
     <van-card
        v-for="v in car"
        :key="v.id"
        :price="v.price.toFixed(2)"
        :desc="v.desc"
        :title="v.title"
        :thumb="v.url"
        @click="toDetail(v.id)"
    />
  </div>
</template>


<script>
export default {
  name: 'car',
  computed: {
    car() {
      return this.$store.state.car
    }
  },
  methods: {
    toDetail(id) {
      this.$router.push({
        name: 'detail',
        // 动态路由参数
        params: {
          id,
        }
      })
    }
  },
  created() {
    this.$store.dispatch('GET_CAR')
  }
}
</script>